//
//  STAddressTableViewCell.m
//  KunLun
//
//  Created by Mac on 2017/11/27.
//  Copyright © 2017年 stoneobs@icloud.com. All rights reserved.
//

#import "STAddressTableViewCell.h"
@interface STAddressTableViewCell()
@property(nonatomic, strong) STLabel                     *titleLable;
@property(nonatomic, strong) STLabel                     *addressLable;
@property(nonatomic, strong) UIView                      *lineView;
@end
@implementation STAddressTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self == [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self configSubView];
    }
    return self;
}
#pragma mark --subView
- (void)configSubView{
    self.backgroundColor = [UIColor whiteColor];
    self.titleLable = [[STLabel alloc] initWithFrame:CGRectMake(10, 0, UIScreenWidth - 20, 30)
                                                text:@"stoneobs    18380461887"
                                           textColor:FirstTextColor
                                                font:15
                                         isSizetoFit:NO
                                       textAlignment:NSTextAlignmentLeft];
    [self addSubview:self.titleLable];
    
    self.addressLable = [[STLabel alloc] initWithFrame:CGRectMake(10, self.titleLable.st_bottom, UIScreenWidth - 20, 40)
                                                  text:@"中国四川省成都市高新区双流县天府大道南段美年广场b318第三方递四方速递佛挡杀佛水电费"
                                             textColor:SecendTextColor
                                                  font:14
                                           isSizetoFit:NO
                                         textAlignment:NSTextAlignmentLeft];
    self.addressLable.numberOfLines = 0;
    [self addSubview:self.addressLable];
    
    self.lineView = [[UIView alloc] initWithFrame:CGRectMake(10, self.addressLable.st_bottom + 3, UIScreenWidth - 20, 1)];
    self.lineView.backgroundColor = KL_lineColor;
    [self addSubview:self.lineView];
    
    self.defultButton = [[STButton alloc] initWithFrame:CGRectMake(10, _lineView.st_bottom + 10, 100, 24)
                                                  title:@"默认地址"
                                             titleColor:SecendTextColor
                                              titleFont:12
                                           cornerRadius:0
                                        backgroundColor:nil
                                        backgroundImage:nil
                                                  image:[UIImage imageNamed:@"PC_gouxuan_background"]];
    self.defultButton.titleEdgeInsets = UIEdgeInsetsMake(0, 5, 0, 0);
    [self.defultButton setImage:[UIImage imageNamed:@"PC_gouxuan__selected_red"] forState:UIControlStateSelected];
    [self addSubview:self.defultButton];
    
    self.delButton = [[STButton alloc] initWithFrame:CGRectMake(10, _lineView.st_bottom + 10, 80, 24)
                                               title:@"删除"
                                          titleColor:SecendTextColor
                                           titleFont:12
                                        cornerRadius:0
                                     backgroundColor:nil
                                     backgroundImage:nil
                                               image:[UIImage imageNamed:@"img_mine_address_del"]];
    self.delButton.titleEdgeInsets = UIEdgeInsetsMake(0, 5, 0, 0);
    self.delButton.st_right = UIScreenWidth - 10;
    [self addSubview:self.delButton];
    
    self.editButton = [[STButton alloc] initWithFrame:CGRectMake(10, _lineView.st_bottom + 10, 100, 24)
                                                title:@"编辑"
                                           titleColor:SecendTextColor
                                            titleFont:12
                                         cornerRadius:0
                                      backgroundColor:nil
                                      backgroundImage:nil
                                                image:[UIImage imageNamed:@"img_mine_addressEdit"]];
    self.editButton.titleEdgeInsets = UIEdgeInsetsMake(0, 5, 0, 0);
    self.editButton.st_right = self.delButton.st_left - 10;
    [self addSubview:self.editButton];
}
- (void)setModel:(STAddressModel *)model{
    _model = model;
    
    self.titleLable.text = [NSString stringWithFormat:@"%@   %@",model.name,model.telephone];

    self.addressLable.text = [NSString stringWithFormat:@"%@%@%@%@",model.province,model.city,model.district,model.address];

    self.defultButton.selected = model.isDefault;
    
    
}
@end
